<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>盒子添加引用-右上角存在一个三角形</title>
</head>

<body>
    <div class="wrap">
        <div class="right"></div>
        <div class="box">
            <div class="boxRight"></div>
        </div>
    </div>
    <style>
        .wrap{
            position: relative;
            width: 100px;
            height: 100px;
        }
        .box {
            width: 100px;
            height: 100px;
            background-color: #f0f0f0;
            position: relative;
            border: solid 4px pink;
            clip-path: polygon(0 0, calc(100% - 20px) 0, 100% 20px, 100% 100%, 0 100%);
        }

        .boxRight {
            position: absolute;
            top: -1px;
            right: -1px;
            width: 20px;
            height: 20px;
            background-color: transparent;
        }

        .boxRight::before,
        .boxRight::after {
            content: '';
            position: absolute;
            width: 0;
            height: 0;
        }

        .boxRight::before {
            top: 0;
            right: 0;
            border-top: 20px solid pink;
            border-left: 20px solid transparent;
        }
        .right {
            position: absolute;
            width: 20px;
            height: 20px;
            top: 0px;
            right: -10px;
            background-color: transparent;
        }

        .right:after {
            content: '';
            position: absolute;
            top: 0;
            right: 0;
            width: 0;
            height: 0;
            z-index: 99;
            border-left: 20px solid transparent;
            border-right: 20px solid rgba(0, 0, 0, 0.2);
            border-bottom: 20px solid transparent;
        }
    </style>
</body>

</html>